require(["common", "hash_routie", "coAjax", "queryString", "jQuery", "browser", "href"], function(jSouper, hash_routie, coAjax, QueryString, $, browser, href) {
	/*
	 * 商家信息并为其配置HASH路由
	 */
	var permission_error_vm = jSouper.parse("<h1>权限不足</h1>")(App);
	window.showLoader();
	coAjax.get(appConfig.bus.loginer, function(data) {
		window.busInfo = data.result;
		App.set("bus_loginer", busInfo);
		if (busInfo._current_employee) {
			var loginer_perms = [];
			jSouper.forEach(busInfo._current_employee.perms, function(permission_key) {
				loginer_perms.push.apply(loginer_perms, permission_key.split("|"));
			});
			App.set("$Cache.perms", loginer_perms);
		}
		hash_routie({
			html_url: "./pages/mb/admin/",
			js_url: "./js/mobile/admin/",
			hash_prefix: "default/:page",
			default_hash: loginer_perms ? (loginer_perms.indexOf("order") !== -1 ? "order" : loginer_perms[0]) : "order",
			teleporter: "main",
			before_handle: function(hash_key, _viewModules) {
				if (loginer_perms && loginer_perms.indexOf(hash_key) === -1) {
					alert("error", "权限不足")
					_viewModules[hash_key] = permission_error_vm;
				}
			}
		});
		window.removeLoader();
	}, function(errorCode) {
		console.log(errorCode);
		switch (errorCode) {
			case "JSON Parse Error":
				break;
			default:
				href.toBusLogin();
		}
	});
	//届时会换成"/"+busInfo._id
	App.set("base_url", "");
});